package com.iscas.dataaggregation.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.iscas.dataaggregation.domain.experiment.OtelTraces;
import com.iscas.dataaggregation.mapper.clickhouse.OtelTracesMapper;
import com.iscas.dataaggregation.service.OtelTracesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.Collections;
import java.util.List;

/**
* @author mj
* @description 针对表【otel_traces】的数据库操作Service实现
* @createDate 2024-11-24 16:13:49
*/
@Service
public class OtelTracesServiceImpl extends ServiceImpl<OtelTracesMapper, OtelTraces>
    implements OtelTracesService {

    @Autowired
    private OtelTracesMapper otelTracesMapper;
    @Override
    public List<OtelTraces> findTracesByTimeAndNamespace(Long from, Long to, String namespace) {
        Timestamp start = new Timestamp(from);
        Timestamp end = new Timestamp(to);

        // 查询匹配的 trace 数据
        List<OtelTraces> traces = otelTracesMapper.findTracesByTimeAndNamespace(start, end, namespace);

        // 输出查询结果
        if (traces == null || traces.isEmpty()) {
            System.out.println("No traces found for namespace: " + namespace);
        } else {
            System.out.println("Traces found for namespace: " + namespace);
        }
        return traces;
    }
}




